// 仅示例
import request from "@renderer/utils/request";
import requestBasic from "@renderer/utils/requestBasic";

// 登录接口
export function loginCache(username, password, phone, verificationCode) {
  const data = {
    userName: username,
    password,
    phone,
    verificationCode,
  };
  return requestBasic({
    url: "/sso/check/loginCache",
    method: "post",
    data,
  });
}
//内部退出登录
export function loginOutInner() {
  return requestBasic({
    url: "/sso/check/logout",
    method: "post",
  });
}
// 获取短信验证码
export function getSMSCode(phone) {
  return requestBasic({
    url: `/sso/check/verificationCode/${phone}`,
    method: "get",
  });
}
// 注册接口
export function register(personName, personPwd, mobilePhone, verificationCode) {
  const data = {
    personName,
    personPwd,
    mobilePhone,
    verificationCode,
  };
  return request({
    url: "/publish/register",
    method: "post",
    data,
  });
}

// 外部用户登录接口
export function loginByPwd(personName, personPwd) {
  const data = {
    personName,
    personPwd,
  };
  return request({
    url: "/publish/loginByPwd",
    method: "post",
    data,
  });
}
// 外部用户手机验证码登录
export function loginByPhone(mobilePhone, verificationCode) {
  const data = {
    mobilePhone,
    verificationCode,
  };
  return request({
    url: "/publish/loginByPhone",
    method: "post",
    data,
  });
}
// 外部退出登录
export function LogOut() {
  return request({
    url: "/publish/logout",
    method: "post",
  });
}

// 获取用户信息
export function getUserInfo() {
  return request({
    url: "/publish/getInfo",
    method: "post",
  });
}

// 获取短信验证码(外部用户)
export function sendCode(mobilePhone) {
  return request({
    url: `/publish/sendCode`,
    method: "get",
    params: { mobilePhone },
  });
}
// 修改密码
export function updatePwdByCode(mobilePhone, verificationCode, personPwd) {
  const data = {
    mobilePhone,
    verificationCode,
    personPwd,
  };
  return request({
    url: "/publish/updatePwdByCode",
    method: "put",
    data: data,
  });
}
